package easyjava.struct;

public class Pair {
	
	private String key;
	private Object value;
	
	public Pair(String key,Object value) {
		this.key = key;
		this.value = value;
	}
	
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Pair) {
			Pair other=(Pair)obj;
			boolean keyEquals = (this.key==null&&other.key==null) || this.key.equals(other.key);
			boolean valueEquals = (this.value==null&&other.value==null) || this.value.equals(other.value);
			return keyEquals && valueEquals;
		}else {
			return super.equals(obj);
		}
	}
	
	@Override
	public String toString() {
		return "Pair{" +
				"key='" + key + '\'' +
				", value=" + value +
				'}';
	}
}
